package com.ruoyi.web.controller.control;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.control.domain.MonkeyVehicle;
import com.ruoyi.control.service.IMonkeyVehicleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 猴车Controller
 *
 * @author ruoyi
 * @date 2024-12-13
 */
@RestController
@RequestMapping("/monkeyVehicle/monkeyVehicle")
public class MonkeyVehicleController extends BaseController
{
    @Autowired
    private IMonkeyVehicleService monkeyVehicleService;

    /**
     * 查询猴车列表
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:list')")
    @GetMapping("/list")
    public TableDataInfo list(MonkeyVehicle monkeyVehicle)
    {
        startPage();
        List<MonkeyVehicle> list = monkeyVehicleService.selectMonkeyVehicleList(monkeyVehicle);
        return getDataTable(list);
    }

    /**
     * 导出猴车列表
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:export')")
    @Log(title = "猴车", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MonkeyVehicle monkeyVehicle)
    {
        List<MonkeyVehicle> list = monkeyVehicleService.selectMonkeyVehicleList(monkeyVehicle);
        ExcelUtil<MonkeyVehicle> util = new ExcelUtil<MonkeyVehicle>(MonkeyVehicle.class);
        util.exportExcel(response, list, "猴车数据");
    }

    /**
     * 获取猴车详细信息
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:query')")
    @GetMapping(value = "/{tagName}")
    public AjaxResult getInfo(@PathVariable("tagName") String tagName)
    {
        return success(monkeyVehicleService.selectMonkeyVehicleByTagName(tagName));
    }

    /**
     * 获取实时运行状态
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:query')")
    @GetMapping(value = "/getSSData")
    public AjaxResult getSSData()
    {
        return success(monkeyVehicleService.getSSData());
    }
    /**
     * 获取操作台操作部分
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:query')")
    @GetMapping(value = "/getControlData")
    public AjaxResult getControlData()
    {
        return success(monkeyVehicleService.getControlData());
    }
    /**
     * 获取状态部分
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:query')")
    @GetMapping(value = "/getStatusData")
    public AjaxResult getStatusData()
    {
        return success(monkeyVehicleService.getStatusData());
    }
    /**
     * 获取指示部分
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:query')")
    @GetMapping(value = "/getIndicatorData")
    public AjaxResult getIndicatorData()
    {
        return success(monkeyVehicleService.getIndicatorData());
    }
    /**
     * 新增猴车
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:add')")
    @Log(title = "猴车", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonkeyVehicle monkeyVehicle)
    {
        return toAjax(monkeyVehicleService.insertMonkeyVehicle(monkeyVehicle));
    }

    /**
     * 修改猴车
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:edit')")
    @Log(title = "猴车", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonkeyVehicle monkeyVehicle)
    {
        return toAjax(monkeyVehicleService.updateMonkeyVehicle(monkeyVehicle));
    }

    /**
     * 删除猴车
     */
    @PreAuthorize("@ss.hasPermi('monkeyVehicle:monkeyVehicle:remove')")
    @Log(title = "猴车", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tagNames}")
    public AjaxResult remove(@PathVariable String[] tagNames)
    {
        return toAjax(monkeyVehicleService.deleteMonkeyVehicleByTagNames(tagNames));
    }
}
